$(document).ready(function(){
   /* Main-menu */
   $('.menu li').hover(function(){
      $(this).find('ul:first').css({
         visibility: 'visible', 
         display: 'none'
      }).show(333);
   }, function(){
      $(this).find('ul:first').css({
         visibility: 'hidden'
      });
   });
   
   /* Khi chuột hover qua ảnh */
   $('.item').hover(function(){
      var src_img = $(this).find('.img-intro').attr('src');
      $('<img width="300" class="tooltip-img" style="z-index:9999" />').attr('src', src_img).appendTo('body').fadeIn(300);
      
   },function(){
      $('.tooltip-img').remove();
      
   }).mousemove(function(e){

      var mousex, mousey;
      if(e.clientX > screen.width - 500)
         mousex = e.pageX - 310;
      else
         mousex = e.pageX + 10;
      
      if(e.clientY > screen.height - 500)
         mousey = e.pageY - 300;
      else
         mousey = e.pageY;
      
      $('.tooltip-img').css({
         top: mousey, 
         left: mousex
      });
   });
   
   /* Add class cho menu khuyen-mai */
   var obj_arr = $('#main-menu').find('li a');
   $.each(obj_arr, function(key, element) {
//      console.log('key: ' + key + '\n' + 'value: ' + element);
      var str = element + "";
      if(str.search("khuyen-mai") != -1){
         $(this).addClass('khuyen-mai');
         var url = $('#logo a').attr('data-template-url');
         var new_image_src = url + '/skin1/images/new.gif';
         $(this).append('<img src="'+ new_image_src + '" />');
      }
   });
});


